package com.suixinsanren.design.state.study.demo02;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

public class GumballMachineTestDrive {

    private GumballMachine gumballMachine;
    private HasQuarterState hasQuarterState;
    private NoQuarterState noQuarterState;
    private SoldOutState soldOutState;
    private SoldState soldState;

    @Before
    public void init() {
        gumballMachine = new GumballMachine(5);
        hasQuarterState = new HasQuarterState(gumballMachine);
        noQuarterState = new NoQuarterState(gumballMachine);
        soldOutState = new SoldOutState(gumballMachine);
        soldState = new SoldState(gumballMachine);
        System.out.println(gumballMachine);
    }

    @After
    public void after() {
        System.out.println(gumballMachine);
        System.out.println("---------------------------");
    }

    @Test
    public void testDmo01() {
        gumballMachine.insertQuarter();
        gumballMachine.turnCrank();
    }

    @Test
    public void testDemo02() {
        gumballMachine.insertQuarter();
        gumballMachine.ejectQuarter();
        gumballMachine.turnCrank();
    }

    @Test
    public void testDemo03() {
        gumballMachine.insertQuarter();
        gumballMachine.turnCrank();
        gumballMachine.insertQuarter();
        gumballMachine.turnCrank();
        gumballMachine.ejectQuarter();
    }

    @Test
    public void testDemo04() {
        gumballMachine.insertQuarter();
        gumballMachine.insertQuarter();
        gumballMachine.turnCrank();
        gumballMachine.insertQuarter();
        gumballMachine.turnCrank();
        gumballMachine.insertQuarter();
        gumballMachine.turnCrank();
    }
}
